﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ServiceStack.Redis;

namespace MdbPhoneBook.Dal
{
    internal class RedisDal
    {
        public void LogStatistic(string name = "")
        {
            string strGetIntValue = "";

            using (var redisClient = new RedisClient())
            {
                if (string.IsNullOrWhiteSpace(name))
                {
                    string testkey = "testKey";
                    redisClient.IncrementValue(testkey);
                }
                else
                {
                    redisClient.IncrementItemInSortedSet("SearchQueries", name, 1);
                }
            }
        }

        //public void GetStatistic(string name = "")
        //{

        /*
         Reading chars from Redis are returned as byte array
         * 
         * 
            byte[] value = new byte[] {0xd7, 0x90, 0xd7, 0x95, 0xd7, 0xa8, 0xd7, 0x99};
            
            var utf8 = new UTF8Encoding();
            var chars = utf8.GetChars(value);
         
         */

        //    string strGetIntValue = "";

        //    using (var redisClient = new RedisClient())
        //    {
        //        if (string.IsNullOrWhiteSpace(name))
        //        {
        //            string testkey = "testKey";
        //            redisClient.Get(testkey);
        //        }
        //        else
        //        {
        //            redisClient.IncrementItemInSortedSet("SearchQueries", name, 1);
        //        }
        //    }
        //}

    }
}
